package health.lm.com.home.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.home.R;
import health.lm.com.home.entity.HomePageEntity;

/**
 * 首页资讯列表 普通列表
 * @author Administrator
 */

public class HomePageAdapter extends BaseQuickAdapter<HomePageEntity,BaseViewHolder> {
    /*2、视频数据。其他普通数据*/
    private int type = 1;

    /**
     * 视频布局
     * @param data 数据源
     * @param type 类型 2为视频
     */
    public HomePageAdapter(@Nullable List<HomePageEntity> data,int type) {
        super(R.layout.item_home_video_page, data);
        this.type = type;
    }

    public HomePageAdapter(@Nullable List<HomePageEntity> data) {
        super(R.layout.item_home_page, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomePageEntity item) {
        if (type == 1) {
            helper.setText(R.id.tv_content_title, item.getTitle())
                    .setText(R.id.tv_content_type, item.getType())
                    .setText(R.id.tv_content_reading, item.getClick() + "阅读")
                    .setText(R.id.tv_content_type, item.getType());
            ImageLoaderHelper.getInstance().load(mContext, item.getPic(), helper.getView(R.id.iv_content_pic));
        } else if (type == 2) {
            helper.setText(R.id.tv_desc,item.getTitle())
                    //.setText(R.id.tv_content_type,item.getType())
                    .setText(R.id.tv_play_num,item.getClick() + "次播放");
            //.setText(R.id.tv_content_type,item.getType());
            ImageLoaderHelper.getInstance().load(mContext,item.getPic(),helper.getView(R.id.iv_video_play));
        }
    }
}
